﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using com.lover.astd.common.config;
using com.lover.astd.common.model;
using com.lover.astd.common;

namespace com.lover.astd.game.ui.server.impl.economy
{
    /// <summary>
    /// 玉石服务(玉石采集)
    /// </summary>
    class StoneServer : LogicServer
    {
        public StoneServer(MainForm frm) { _mainForm = frm; ServerName = ConfigStrings.S_Stone; ServerReadableName = ConfigStrings.SR_Stone; }
        public override void renderSettings()
        {
            MainForm frm = _mainForm;
            Dictionary<string, string> conf = getConfig(ServerName);
            frm.chk_get_stone.Checked = conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true");
            if (conf.ContainsKey(ConfigStrings.ratio))
            {
                int ratio = 0;
                Int32.TryParse(conf[ConfigStrings.ratio], out ratio);
                frm.num_get_stone.Value = ratio;
            }
        }
        public override void saveSettings()
        {
            MainForm frm = _mainForm;
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, frm.chk_get_stone.Checked.ToString());
            conf.setConfig(ServerName, ConfigStrings.ratio, frm.num_get_stone.Value.ToString());
        }
        public override void loadDefaultSettings()
        {
            GameConfig conf = getConfig();
            conf.setConfig(ServerName, ConfigStrings.enabled, "true");
            conf.setConfig(ServerName, ConfigStrings.ratio, "50");
            renderSettings();
        }
    }
}
